#ifndef HTTPMGR_H
#define HTTPMGR_H
#include "singleton.h"
#include <QString>
#include <QUrl>
#include <QObject>
#include <QNetworkAccessManager>
#include <QJsonObject>
#include <QJsonArray> //序列化
#include <QJsonDocument> //反序列化

class Httpmgr: public QObject, public Singleton<Httpmgr>, public std::enable_shared_from_this<Httpmgr>
{
    Q_OBJECT
public:
    //这里析构为公有是CRTP所需要的，因为单例模式智能指针析构，而智能指针模板里面的T为Httpmgr
    //析构会调用Httpmgr的析构，所以需要公有
    ~Httpmgr();
private:
    //这里设置为友元，是为了单例基类在new时不会报错
    friend class Singleton<Httpmgr>;
    Httpmgr();
    QNetworkAccessManager _manger;
    void PostHttpReq(QUrl url, QJsonObject json, ReqId reg_id, Modules mod);
signals:
    void sig_http_finish(ReqId id, QString res, ErrorCodes err, Modules mod);
};

#endif // HTTPMGR_H
